package com.example.ac.util;

import android.content.Context;
import android.media.AudioManager;
import android.util.Log;

import com.example.ac.BuddhaActivity;
import com.example.ac.R;

/**
 * Created by abc on 2019/10/16.
 */

public class SoundPool {
    private static SoundPool soundPoolUtil;
    private static android.media.SoundPool soundPool;

    //单例模式
    public static SoundPool getInstance(Context context) {
        if (soundPoolUtil == null)
            soundPoolUtil = new SoundPool(context);
        return soundPoolUtil;
    }

    private SoundPool(Context context) {
        soundPool = new android.media.SoundPool(2, AudioManager.STREAM_SYSTEM, 0);
        //加载音频文件
        soundPool.load(context, R.raw.shengying, 1);
        soundPool.load(context, R.raw.shengying, 1);
    }

    public static void play(int number) {
        //播放音频
        soundPool.play(number, 1, 1, 0, 0, 1);
    }
}